/**
 * 
 * 起迪科技 Copyright (c) 2014-2018 QiDi,Inc.All Rights Reserved.
 */
package cn.qidisoft.edu.hzjt.service.impl;

import java.util.List;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.qidisoft.core.common.code.QdfRespCode;
import cn.qidisoft.core.common.exception.dao.DBException;
import cn.qidisoft.core.common.log.LoggerAdapter;
import cn.qidisoft.core.common.log.LoggerAdapterFactory;
import cn.qidisoft.edu.hzjt.dao.CommonMapper;
import cn.qidisoft.edu.hzjt.dao.StudentClassMapper;
import cn.qidisoft.edu.hzjt.model.Employee;
import cn.qidisoft.edu.hzjt.model.Grade;
import cn.qidisoft.edu.hzjt.model.Priority;
import cn.qidisoft.edu.hzjt.model.Semester;
import cn.qidisoft.edu.hzjt.model.Specialty;
import cn.qidisoft.edu.hzjt.model.Student;
import cn.qidisoft.edu.hzjt.model.StudentClass;
import cn.qidisoft.edu.hzjt.model.StudentFamily;
import cn.qidisoft.edu.hzjt.model.SysCode;
import cn.qidisoft.edu.hzjt.model.UserEmployee;
import cn.qidisoft.edu.hzjt.service.ICommonService;
import cn.qidisoft.edu.hzjt.utils.LogType;

/**
 * 
 * @author hxq
 * @version $Id: CommonServiceImpl.java, v 0.1 2018年10月25日 下午2:09:18 hxq Exp $
 */
@Service("commonService")
public class CommonServiceImpl implements ICommonService {
    protected static final LoggerAdapter LOGGER = LoggerAdapterFactory
        .getLogger(LogType.HZJT_LOGGER.val);
    @Autowired
    private CommonMapper                 commonMapper;
    @Autowired
    private StudentClassMapper           studentClassMapper;

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryUserByEmployee(cn.qidisoft.edu.hzjt.model.UserEmployee)
     */
    @Override
    public UserEmployee queryUserByEmployee(UserEmployee user) {
        try {
            return commonMapper.queryUserByEmployee(user);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("queryUserByEmployee [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(user, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryStudentByEmployee(cn.qidisoft.edu.hzjt.model.Student)
     */
    @Override
    public Student queryStudentByEmployee(Student student) {
        try {
            return commonMapper.queryStudentByEmployee(student);
        } catch (Exception e) {
            LOGGER.error("queryStudentByEmployee [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(student, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryUserByPriority(cn.qidisoft.edu.hzjt.model.Priority)
     */
    @Override
    public List<Priority> queryUserByPriority(UserEmployee userEmployee) {
        try {
            return commonMapper.queryUserByPriority(userEmployee);
        } catch (Exception e) {
            LOGGER.error("queryUserByPriority [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(userEmployee, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryAllBySemester()
     */
    @Override
    public List<Semester> queryAllBySemester() {
        try {
            return commonMapper.queryAllBySemester();
        } catch (Exception e) {
            LOGGER.error("queryAllBySemester [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(null, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryBySemester(cn.qidisoft.edu.hzjt.model.Semester)
     */
    @Override
    public Semester queryBySemester(Semester semester) {
        try {
            return commonMapper.queryBySemester(semester);
        } catch (Exception e) {
            LOGGER.error("queryBySemester [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(semester, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryAllBySysCode()
     */
    @Override
    public List<SysCode> queryAllBySysCode() {
        try {
            return commonMapper.queryAllBySysCode();
        } catch (Exception e) {
            LOGGER.error("queryAllBySysCode [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(null, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryAllBySpecialty()
     */
    @Override
    public List<Specialty> queryAllBySpecialty(Specialty specialty) {
        try {
            return commonMapper.queryAllBySpecialty(specialty);
        } catch (Exception e) {
            LOGGER.error("queryAllBySpecialty [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(null, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#querySpecialtyByClass(cn.qidisoft.edu.hzjt.model.Specialty)
     */
    @Override
    public StudentClass querySpecialtyByClass(Specialty specialty) {
        try {
            return commonMapper.querySpecialtyByClass(specialty);
        } catch (Exception e) {
            LOGGER.error("querySpecialtyByClass [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(specialty, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryGradeSpecialtyByClass(cn.qidisoft.edu.hzjt.model.StudentClass)
     */
    @Override
    public List<StudentClass> queryGradeSpecialtyByClass(Student student) {
        try {
            return commonMapper.queryGradeSpecialtyByClass(student);
        } catch (Exception e) {
            LOGGER.error(
                "queryGradeSpecialtyByClass [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(student, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryAllByGrade()
     */
    @Override
    public List<Grade> queryAllByGrade(Grade grade) {
        try {
            return commonMapper.queryAllByGrade(grade);
        } catch (Exception e) {
            LOGGER.error("queryAllByGrade [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(null, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryByGrade(cn.qidisoft.edu.hzjt.model.Grade)
     */
    @Override
    public Grade queryByGrade(Grade grade) {
        try {
            return commonMapper.queryByGrade(grade);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("queryByGrade [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(grade, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryGradeByClass(cn.qidisoft.edu.hzjt.model.Grade)
     */
    @Override
    public StudentClass queryGradeByClass(Grade grade) {
        try {
            return commonMapper.queryGradeByClass(grade);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("queryGradeByClass [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(grade, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryStudentClassByBzr(cn.qidisoft.edu.hzjt.model.Student)
     */
    @Override
    public List<Employee> queryStudentClassByBzr(Student student) {
        try {
            return commonMapper.queryStudentClassByBzr(student);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("queryStudentClassByBzr [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(student, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryStudentClassByAllBzr()
     */
    @Override
    public List<Employee> queryStudentClassByAllBzr() {
        try {
            return commonMapper.queryStudentClassByAllBzr();
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error(
                "queryStudentClassByAllBzr [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(null, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryByAllEmployee(cn.qidisoft.edu.hzjt.model.Employee)
     */
    @Override
    public List<Employee> queryByAllEmployee(Employee employee) {
        try {
            return commonMapper.queryByAllEmployee(employee);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("queryByAllEmployee [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(employee, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryByEmployee(cn.qidisoft.edu.hzjt.model.Employee)
     */
    @Override
    public Employee queryByEmployee(Employee employee) {
        try {
            return commonMapper.queryByEmployee(employee);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("queryByEmployee [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(employee, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryNotCurrByAllEmployee(cn.qidisoft.edu.hzjt.model.Employee)
     */
    @Override
    public List<Employee> queryNotCurrByAllEmployee(Employee employee) {
        try {
            return commonMapper.queryNotCurrByAllEmployee(employee);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error(
                "queryNotCurrByAllEmployee [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(employee, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryClassOrGradeByAllStudent(cn.qidisoft.edu.hzjt.model.Student)
     */
    @Override
    public List<Student> queryClassOrGradeByStudent(StudentClass student) {
        try {
            return commonMapper.queryClassOrGradeByStudent(student);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error(
                "queryClassOrGradeByAllStudent [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(student, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryByStudent(cn.qidisoft.edu.hzjt.model.Student)
     */
    @Override
    public Student queryByStudent(Student student) {
        try {
            return commonMapper.queryByStudent(student);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("queryByStudent [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(student, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);

        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryStudentByAllFamily(cn.qidisoft.edu.hzjt.model.StudentFamily)
     */
    @Override
    public List<StudentFamily> queryStudentByAllFamily(StudentFamily studentFamily) {
        try {
            return commonMapper.queryStudentByAllFamily(studentFamily);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error(
                "queryStudentByAllFamily [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(), ToStringBuilder.reflectionToString(studentFamily,
                    ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#querySemesterByStudentConductList(cn.qidisoft.edu.hzjt.model.Student)
     */
    @Override
    public List<Student> querySemesterByStudentConductList(Student student) {
        try {
            return commonMapper.querySemesterByStudentConductList(student);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("querySemesterByStudentConductList [{}] error," + this.getClass().getName()
                         + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(student, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#querySemesterStudentScoreConductList(cn.qidisoft.edu.hzjt.model.Student)
     */
    @Override
    public List<Student> querySemesterStudentScoreConductList(Student student) {
        try {
            return commonMapper.querySemesterStudentScoreConductList(student);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("querySemesterStudentScoreConductList [{}] error,"
                         + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(student, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryClassStudentCount(cn.qidisoft.edu.hzjt.model.Student)
     */
    @Override
    public int queryClassStudentCount(Student student) {
        try {
            return commonMapper.queryClassStudentCount(student);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("queryClassStudentCount [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(student, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryAllByYear()
     */
    @Override
    public List<Semester> queryAllByYear() {
        try {
            return commonMapper.queryAllByYear();
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("queryAllByYear [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(null, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryYearBySemester(cn.qidisoft.edu.hzjt.model.Semester)
     */
    @Override
    public List<Semester> queryYearBySemester(Semester semester) {
        try {
            return commonMapper.queryYearBySemester(semester);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("queryYearBySemester [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(semester, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryByStudentConduct(cn.qidisoft.edu.hzjt.model.Student)
     */
    @Override
    public Student queryByStudentConduct(Student student) {
        try {
            return commonMapper.queryByStudentConduct(student);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("queryByStudentConduct [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(student, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryStudentClass(java.lang.Integer)
     */
    @Override
    public StudentClass queryStudentClass(Integer bjid) {
        try {
            return studentClassMapper.queryByPK(bjid);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("queryStudentClass [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(bjid, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /**
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#queryUserClassByValdateBzr(cn.qidisoft.edu.hzjt.model.UserEmployee)
     */
    @Override
    public int queryUserClassByValdateBzr(UserEmployee user) {
        try {
            return commonMapper.queryUserClassByValdateBzr(user);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error(
                "queryUserClassByValdateBzr [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(user, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

    /** 
     * @see cn.qidisoft.edu.hzjt.service.ICommonService#getqueryStudentClassByBzr(cn.qidisoft.edu.hzjt.model.Student)
     */
    @Override
    public List<Employee> getqueryStudentClassByBzr(Student student) {
        try {
            return commonMapper.getqueryStudentClassByBzr(student);
        } catch (Exception e) {
            e.printStackTrace();
            LOGGER.error("queryStudentClassByBzr [{}] error," + this.getClass().getName() + "=[{}]",
                this.getClass().getName(),
                ToStringBuilder.reflectionToString(student, ToStringStyle.SHORT_PREFIX_STYLE));
            throw new DBException(QdfRespCode.QDF_020002.getCode(), QdfRespCode.QDF_020002.getMsg(),
                e);
        }
    }

}
